﻿#include "mediator.h"

#include "global.h"


unsigned int PLCMessageThread(void *p){
    std::cout <<"start thread" <<std::endl;
    return 0;
}

Mediator::Mediator()
{


        BUniMap[Baund1200] = QSerialPort::Baud1200;
        BUniMap[Baund2400] = QSerialPort::Baud2400;
        BUniMap[Baund4800] = QSerialPort::Baud4800;
        BUniMap[Baund9600] = QSerialPort::Baud9600;
        BUniMap[Baund19200] = QSerialPort::Baud19200;
        BUniMap[Baund38400] = QSerialPort::Baud38400;
        BUniMap[Baund57600] = QSerialPort::Baud57600;
        BUniMap[Baund115200] = QSerialPort::Baud115200;

        PUniMap[PARNONE] = QSerialPort::NoParity;
        PUniMap[PARODD] = QSerialPort::OddParity;
        PUniMap[PAREVEN] = QSerialPort::EvenParity;

        DUniMap[DATA7] = QSerialPort::Data7;
        DUniMap[DATA8] = QSerialPort::Data8;

        SUniMap[STOP1] = QSerialPort::OneStop;
        SUniMap[STOP1D5] = QSerialPort::OneAndHalfStop;
        SUniMap[STOP2] = QSerialPort::TwoStop;

        serials = new Serials();
        (HANDLE)_beginthreadex(NULL, 0,PLCMessageThread, this, 0, NULL);
        connect(serials,&QSerialPort::readyRead,[=](){recvMsg();});
    }
